import React from 'react'
import PropTypes from 'prop-types'
import {Table, Modal, Badge} from 'antd'
import classnames from 'classnames'
import {randomColor} from 'config'
import {DropOption} from 'components'
import AnimTableBody from 'components/DataTable/AnimTableBody'
import styles from './List.less'


const {confirm} = Modal

const List = ({
                onDeleteItem, onLeaveItem, onEditItem, isMotion, location, ...tableProps
              }) => {

  const handleMenuClick = (record, e) => {
    if (e.key === 'edit') {
      onEditItem(record)
    } else if (e.key === 'view') {
      onEditItem(record, true)
    }  else if (e.key === 'delete') {
      confirm({
        title: '您确定要删除这条数据吗?',
        okText: '确定',
        cancelText: '取消',
        onOk () {
          onDeleteItem(record.id)
        },
      })
    }
  }

  const getAvatarText = (realName) => {
    return realName ? realName.substr(realName.length - 1, realName.length) : ""
  }



  const columns = [
     {
      title: '好友微信号',
      dataIndex: 'belongDeptName',
      key: 'belongDeptName',

    }, {
      title: '好友昵称',
      dataIndex: 'friendNickName',
      key: 'friendNickName',
    }, {
      title: '好友备注',
      dataIndex: 'friendRemark',
      key: 'friendRemark',

    }, {
      title: '方向',
      dataIndex: 'msgDirection',
      key: 'msgDirection',

    }, {
      title: '方式',
      dataIndex: 'ways',
      key: 'ways',

    }, {
      title: '金额',
      dataIndex: 'amount',
      key: 'amount',
      render:(val) => val + '元',

    }, {
      title: '转账时间',
      dataIndex: 'transferTime',
      key: 'transferTime',

    }, {
      title: '记录详情',
      dataIndex: 'detail',
      key: 'detail',

    },
  ]

  const AnimateBody = (props) => {
    return <AnimTableBody {...props} />
  }

  const CommonBody = (props) => {
    return <tbody {...props} />
  }

  return (
    <Table
      {...tableProps}
      className={classnames(styles.table, {[styles.motion]: isMotion})}
      scroll={{x: 1500}}
      columns={columns}
      simple
      rowKey={record => record.id}
      components={{
        body: {wrapper: isMotion ? AnimateBody : CommonBody},
      }}
    />
  )
}

List.propTypes = {
  onDeleteItem: PropTypes.func,
  onEditItem: PropTypes.func,
  isMotion: PropTypes.bool,
  location: PropTypes.object,
}

export default List
